package com.xplay.xpocker.room.mahjong.dto;

import com.xplay.xpocker.constant.ConstantDict;
import com.xplay.xpocker.constant.RoomTypeEnum;
import com.xplay.xpocker.util.ObjectUtils;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

public class MahjongRules {
    public static MahjongRules INSTANCE = new MahjongRules();

    private HashMap<String, Map<String, String>> allMahjongRules = new HashMap<>();


    private MahjongRules() {
        allMahjongRules.put(RoomTypeEnum.CD_MAHJONG.code, Arrays.stream(CdRuleEnum.values()).collect(Collectors.toMap(CdRuleEnum::getCode, CdRuleEnum::getName)));
        allMahjongRules.put(RoomTypeEnum.WZ_MAHJONG.code, Arrays.stream(WzRuleEnum.values()).collect(Collectors.toMap(WzRuleEnum::getCode, WzRuleEnum::getName)));
    }

    public Map<String, String> getRules(String type) {
        return allMahjongRules.get(type);
    }

    public boolean existsRule(String type, String rule) {
        Map<String, String> rules = allMahjongRules.get(type);
        return rules != null && rules.containsKey(rule);
    }
}
